% Counter-factual Table

clc
clear all
close all

load cnt_original.mat
Stime_original=Stime;
Ftime_sum(:,1)=sum(Ftime(:,:,1),2);
Ftime_sum(:,2)=sum(Ftime(:,:,2),2);
Ftime_sum_original=Ftime_sum;
total_cum_Dtime_original=total_cum_Dtime;
utility_sum_norm_avg_original=utility_sum_norm_avg;
utility_sum_norm_young_original=utility_sum_norm_young;
utility_sum_norm_old_original =utility_sum_norm_old;

load cnt_delta1_0.mat
Stime_cnt0=Stime;
Ftime_sum(:,1)=sum(Ftime(:,:,1),2);
Ftime_sum(:,2)=sum(Ftime(:,:,2),2);
Ftime_sum_cnt0=Ftime_sum;
total_cum_Dtime_cnt0=total_cum_Dtime;
utility_sum_norm_avg_cnt0=utility_sum_norm_avg;
utility_sum_norm_young_cnt0=utility_sum_norm_young;
utility_sum_norm_old_cnt0 =utility_sum_norm_old;

load cnt_delta2_0.mat
Stime_cnt1=Stime;
Ftime_sum(:,1)=sum(Ftime(:,:,1),2);
Ftime_sum(:,2)=sum(Ftime(:,:,2),2);
Ftime_sum_cnt1=Ftime_sum;
total_cum_Dtime_cnt1=total_cum_Dtime;
utility_sum_norm_avg_cnt1=utility_sum_norm_avg;
utility_sum_norm_young_cnt1=utility_sum_norm_young;
utility_sum_norm_old_cnt1=utility_sum_norm_old;

% chaining

Stime_cnt1=(Stime_cnt1+Stime_cnt0)/2;
Ftime_sum_cnt1=(Ftime_sum_cnt1+Ftime_sum_cnt0)/2;
total_cum_Dtime_cnt1=(total_cum_Dtime_cnt1+total_cum_Dtime_cnt0)/2;
utility_sum_norm_avg_cnt1=(utility_sum_norm_avg_cnt1+utility_sum_norm_avg_cnt0)/2;
utility_sum_norm_young_cnt1=(utility_sum_norm_young_cnt1+utility_sum_norm_young_cnt0)/2;
utility_sum_norm_old_cnt1=(utility_sum_norm_old_cnt1+utility_sum_norm_old_cnt0)/2;

load cnt_delta1_0_delta2_0.mat
Stime_cnt2=Stime;
Ftime_sum(:,1)=sum(Ftime(:,:,1),2);
Ftime_sum(:,2)=sum(Ftime(:,:,2),2);
Ftime_sum_cnt2=Ftime_sum;
total_cum_Dtime_cnt2=total_cum_Dtime;
utility_sum_norm_avg_cnt2=utility_sum_norm_avg;
utility_sum_norm_young_cnt2=utility_sum_norm_young;
utility_sum_norm_old_cnt2=utility_sum_norm_old;

load cnt_lockdown.mat
Stime_lockdown=Stime;
Ftime_sum(:,1)=sum(Ftime(:,:,1),2);
Ftime_sum(:,2)=sum(Ftime(:,:,2),2);
Ftime_sum_lockdown=Ftime_sum;
total_cum_Dtime_lockdown=total_cum_Dtime;
utility_sum_norm_avg_lockdown=utility_sum_norm_avg;
utility_sum_norm_young_lockdown=utility_sum_norm_young;
utility_sum_norm_old_lockdown=utility_sum_norm_old;

%% Table

end_day=365*2; % in one and half years

% 1. total number of infection
tab(1,1)=total_cum_Dtime_cnt2(end_day,1);
tab(1,2)=total_cum_Dtime_cnt1(end_day,1);
tab(1,3)=total_cum_Dtime_original(end_day,1);
tab(1,4)=total_cum_Dtime_lockdown(end_day,1);

% 2. total number of death (age 20-59)
tab(2,1)=Ftime_sum_cnt2(end_day,1)+Ftime_sum_cnt2(end_day,2);
tab(2,2)=Ftime_sum_cnt1(end_day,1)+Ftime_sum_cnt1(end_day,2);
tab(2,3)=Ftime_sum_original(end_day,1)+Ftime_sum_original(end_day,2);
tab(2,4)=Ftime_sum_lockdown(end_day,1)+Ftime_sum_lockdown(end_day,2);
tab(3,1)=Ftime_sum_cnt2(end_day,1);
tab(3,2)=Ftime_sum_cnt1(end_day,1);
tab(3,3)=Ftime_sum_original(end_day,1);
tab(3,4)=Ftime_sum_lockdown(end_day,1);
tab(4,1)=Ftime_sum_cnt2(end_day,2);
tab(4,2)=Ftime_sum_cnt1(end_day,2);
tab(4,3)=Ftime_sum_original(end_day,2);
tab(4,4)=Ftime_sum_lockdown(end_day,2);

% 4. utility loss per day

tab(5,1)=-(nansum(utility_sum_norm_avg_cnt2(1:end_day,1)))/(end_day)*100;
tab(5,2)=-(nansum(utility_sum_norm_avg_cnt1(1:end_day,1)))/(end_day)*100;
tab(5,3)=-(nansum(utility_sum_norm_avg_original(1:end_day,1)))/(end_day)*100;
tab(5,4)=-(nansum(utility_sum_norm_avg_lockdown(1:end_day,1)))/(end_day)*100;
tab(6,1)=-(nansum(utility_sum_norm_young_cnt2(1:end_day,1)))/(end_day)*100;
tab(6,2)=-(nansum(utility_sum_norm_young_cnt1(1:end_day,1)))/(end_day)*100;
tab(6,3)=-(nansum(utility_sum_norm_young_original(1:end_day,1)))/(end_day)*100;
tab(6,4)=-(nansum(utility_sum_norm_young_lockdown(1:end_day,1)))/(end_day)*100;
tab(7,1)=-(nansum(utility_sum_norm_old_cnt2(1:end_day,1)))/(end_day)*100;
tab(7,2)=-(nansum(utility_sum_norm_old_cnt1(1:end_day,1)))/(end_day)*100;
tab(7,3)=-(nansum(utility_sum_norm_old_original(1:end_day,1)))/(end_day)*100;
tab(7,4)=-(nansum(utility_sum_norm_old_lockdown(1:end_day,1)))/(end_day)*100;

save ('Output/table2.mat', 'tab')